package com.example.spring_musicserver_1113.config;

import com.example.spring_musicserver_1113.model.User;
import com.example.spring_musicserver_1113.tools.Constant;
import com.example.spring_musicserver_1113.tools.ResponseBodyMessage;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @version 1.0
 * @Author 作者名
 * @Date 2024/11/17 23:07
 * @注释
 */
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public  boolean preHandle(HttpServletRequest request,
                              HttpServletResponse response,
                              Object handler) throws Exception {
        HttpSession httpSession = request.getSession(false);
        if(httpSession != null || httpSession.getAttribute(Constant.USERINFO_SESSION_KEY) != null){
            System.out.println("已经登录！");
            return true;
        }
        return false;
    }
}
